/**
 * Created by dywu on 2015/9/24.
 */
angular.module('preferential.service.userbalance', ['ngResource'])

    //county
    .service('UserBalanceService', ['$resource', function ($resource) {
        //var resource = $resource(authurl + "userbalance/:id");
        //this.getbyid = function (id) {
        //    return resource.get({id: id});
        //}
        //this.add = function (userbalance,success,error) {
        //    return resource.save({},userbalance,success,error);
        //}
        //this.update = function (id,userbalance,success,error) {
        //    return resource.save({id:id},userbalance,success,error);
        //}
        //this.remove = function (id) {
        //    return resource.remove({id:id});
        //}
        //this.getlist = function () {
        //    return resource.query();
        //}

        var resource = $resource(activityURL + "ActivityAll");
        this.activityAdd = function (activity,success,error) {
            return resource.save({},activity,success,error);
        }

        this.getactivityall = function(page,success,error){
           return resource.query({pageIndex:page.pageIndex,pageSize:page.pageSize},success,error);
        }

        this.getactivitybyid = function (id) {
            var resource = $resource(activityURL + "ActivityAll/:activityId");
            return resource.get({activityId: id});
        }

        this.advisetime = function(id,activity,success,error){
            var resource = $resource(activityURL + "ActivityCondition/:activityId/settime");
            return resource.save({activityId:id},activity,success,error);
        }

        this.devisercondition = function(id,activity,success,error){
            var resource = $resource(activityURL + "ActivityCondition/:activityId");
            return resource.save({activityId:id},activity,success,error);
        }

        this.deviserule = function(id,activity,success,error){
            var resource = $resource(activityURL + "ActivityRule/:activityId");
            return resource.save({activityId:id},activity,success,error);
        }

        this.devisertitle = function(id,activity,success,error){
            var resource = $resource(activityURL + "Activity/:activityId");
            return resource.save({activityId:id},activity,success,error);
        }

        this.deleteactivity = function(id,success,error){
            var resource = $resource(activityURL + "ActivityAll/:activityId");
            return resource.remove({activityId:id});
        }
    }])
;
